﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using fsw.Common;
using System.Text;

namespace fsw.Web.Card
{
    public partial class CardAdd : Web.UI.ManagePage
    {
        protected Model.Admin model_admin;//登录用户名
        protected void Page_Load(object sender, EventArgs e)
        {
            model_admin = GetAdminInfo();
            if (model_admin.TypeId == 1)
            {
                Response.Write(JsonErr("success", "复制成功"));
                Response.End();
            }
            if (DTRequest.IsPost())
            {
                Response.Write(DoAdd());
                Response.End();
            }
        }
        protected string DoAdd()
        {
            int UserId = model_admin.Id;
            int Pid = DTRequest.GetFormInt("Pid");
            string PicPath = DTRequest.GetFormString("PicPath");
            string PicName = DTRequest.GetFormString("PicName");
            int AddDate = Utils.ConvertDateTimeInt(DateTime.Now);
            if (Pid == 0) return JsonErr("error", "项目id不能为空");
            if (string.IsNullOrEmpty(PicPath)) return JsonErr("error", "图片路径不能为空");
            if (string.IsNullOrEmpty(PicName)) return JsonErr("error", "图片名称不能为空");
            Model.Admin_Pic model = new Model.Admin_Pic();
            model.UserId = UserId;
            model.Pid = Pid;
            model.PicPath = PicPath;
            model.PicName = PicName;
            model.AddDate = AddDate;
            model.TypeId = 2;
            model.isStatus = 1;
            BLL.Admin_Pic bll = new BLL.Admin_Pic();
            if (bll.Add(model) > 0)
            {
                return JsonErr("success", "复制成功!");
            }
            return JsonErr("error", "参数错误 ");
        }
    }
}